package main

import (
	"fmt"
	"math/rand"
	"strconv"
	"time"
)

type Person struct {
	Amount float64
	Name   string
}

var person = make([]Person, 0)

func main() {

	rand.Seed(time.Now().Unix())

	for i := 0; i < 10; i++ {
		person = append(person, Person{Amount: rand.Float64(), Name: "name:" + strconv.Itoa(i)})
	}

	for i := range person {
		fmt.Println(person[i])
	}

	fmt.Println(">>>>>>>>>. ptr")
	per := getPerson()
	per.Amount = 12
	per.Name = "xiaohui"
	for i := range person {
		fmt.Println(person[i])
	}

	fmt.Println(">>>>>>>>>>>")
	obj := getPersonObj()
	obj.Amount = 20
	obj.Name = "songxiaohui"
	for i := range person {
		fmt.Println(person[i])
	}
}

func getPerson() *Person {
	return &person[0]
}

func getPersonObj() Person {
	return person[1]
}
